package org.jeecg.modules.cascv.image.job;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.C;
import org.jeecg.modules.cascv.image.util.LaptopConstant;
import org.jeecg.modules.message.websocket.WebSocket;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

/**
 * @author;作者
 * @Date 2023/3/6 17:18
 * @Description :
 * @Version
 */
@Component
@Slf4j
public class RealtimeTask {

    @Resource
    private WebSocket webSocket;

    @Scheduled(fixedRate = 3000)
    public void timeTask(){
        for (String s : LaptopConstant.infoMap.keySet()) {
            webSocket.pushMessage(s);
        }
        for (String s : LaptopConstant.timeMap.keySet()) {
            webSocket.pushMessage(s);
        }
        for (String tableName : LaptopConstant.idsFileTableName.asMap().keySet()) {
           // log.info("tableName:"+tableName);
            webSocket.pushMessage("REAL:" + tableName);
          //  webSocket.pushMessage(tableName);
        }
    }
}


/**
 * fixedDelay = 5000 上个任务执行完过5秒再执行
 * fixedRate = 5000  每隔5秒执行
 * 定时执行。任务间隔规定时间即执行。
 * 此处，任务每隔五秒便会执行一次。
 */
